package com.zijidelu.luframework.starter;

import com.zijidelu.luframework.config.properties.LuFrameworkProperties;
import com.zijidelu.luframework.constant.LuFrameworkConstant;
import com.zijidelu.luframework.starter.beans.AutoConfigurationManager;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * 框架自动配置类
 * 负责自动配置框架的核心组件和功能
 * 包括 Jackson 序列化配置、字典翻译、自动扫描等功能
 *
 * @author ZIJIDELU
 * @datetime 2025-11-24 14:00:00
 */
@Slf4j
@Import(AutoConfigurationManager.class)
@AutoConfiguration
@EnableConfigurationProperties(LuFrameworkProperties.class)
@ComponentScan(
        basePackages = LuFrameworkConstant.DEFAULT_SCAN_PACKAGE,
        excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {ControllerAdvice.class, RestControllerAdvice.class})
        }
)
public class LuFrameworkAutoConfiguration {
    /**
     * 在框架自动配置 Bean 初始化完成后执行
     */
    @PostConstruct
    public void onFrameworkBootstrapped() {
        log.info(">>> LuFramework bootstrapped. Scan scope: {}", LuFrameworkConstant.DEFAULT_SCAN_PACKAGE);
    }
}
